package com.xnyzc.lhy.mis.mapper.system;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xnyzc.lhy.mis.entity.result.withdrawalrules.CmsWithdrawalRules;
import com.xnyzc.lhy.mis.entity.system.OaSysAgreement;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 协议相关 Mapper 接口
 * </p>
 *
 * @author liuju
 * @since 2019-09-09
 */
public interface OaSysAgreementMapper extends BaseMapper<OaSysAgreement> {

    @Select("<script>" +
            "SELECT " +
                   "agreement_id," +
                   "parent_id," +
                   "title," +
                   "content,    " +
                   "type       " +
            "FROM  " +
                   "oa_sys_agreement  " +
            "WHERE  " +
                   "deleted=0  " +
                   "AND type in  " +
            "<foreach collection='type' item='item'  index='index' open='(' separator=',' close=')'> \n" +
            "       #{item}   \n" +
            "</foreach>   " +
            "</script>"
    )
    List<CmsWithdrawalRules> getAgreementContent(@Param("type") List<Integer> type);


//    @Select("SELECT content, title FROM oa_sys_agreement WHERE agreement_id = #{parentId}")
//    CmsWithdrawalRules getAgreementContentDetails(@Param("parentId") String parentId);

    @Select("SELECT content, title FROM oa_sys_agreement WHERE type = #{type} limit 0, 1 ")
    CmsWithdrawalRules getAgreementByType(Integer type);

}
